package com.koron.order.workbench.appMenu.controller;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.workbench.appMenu.bean.dto.AppMenuDto;
import com.koron.order.workbench.appMenu.bean.po.AppMenuPo;
import com.koron.order.workbench.appMenu.service.AppMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 个人应用菜单表(AppMenu)表控制层
 *
 * @author zhouj
 * @since 2022-03-18 08:35:26
 */
@Api(tags = "个人应用菜单表(AppMenu)")
@RestController
@RequestMapping("/appMenu/")
public class AppMenuController {

    @Autowired
    private AppMenuService appMenuService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "新增或修改个人应用菜单表")
    @PostMapping("insertOrUpdate")
    public Response<Integer> insertOrUpdate(@RequestBody AppMenuPo appMenu) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), appMenuService, "insertOrUpdate", Integer.class, appMenu));
    }

    @ApiOperation(value = "新增个人应用菜单表")
    @PostMapping("insert")
    public Response<Integer> insert(@RequestBody AppMenuPo appMenu) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), appMenuService, "insert", Integer.class, appMenu));
    }

    @ApiOperation(value = "批量新增个人应用菜单表")
    @PostMapping("insertBatch")
    public Response<Integer> insertBatch(@RequestBody AppMenuDto appMenuDto) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), appMenuService, "insertBatch", Integer.class, appMenuDto));
    }

    @ApiOperation(value = "根据id更新个人应用菜单表")
    @PutMapping("update")
    public Response<Integer> update(@RequestBody AppMenuPo appMenu) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), appMenuService, "update", Integer.class, appMenu));
    }

    @ApiOperation(value = "根据id删除个人应用菜单表")
    @DeleteMapping("deleteById")
    public Response<Integer> deleteById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), appMenuService, "deleteById", Integer.class, id));
    }

    @ApiOperation(value = "根据id查询个人应用菜单表")
    @GetMapping("queryById")
    public Response<AppMenuPo> queryById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), appMenuService, "queryById", AppMenuPo.class, id));
    }

    @ApiOperation(value = "不分页查询个人应用菜单表列表")
    @GetMapping("queryList")
    public Response<List<AppMenuPo>> queryList(AppMenuPo queryVo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), appMenuService, "queryList", List.class, queryVo));
    }

    @ApiOperation(value = "分页查询个人应用菜单表列表")
    @GetMapping("queryPageList")
    public Response<PageInfo> queryPageList(AppMenuPo queryPo, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), appMenuService, "queryPageList", PageInfo.class, queryPo, pageQuery));
    }

}
